Skip to content

util: fix style restoration for nested styleText calls - #67759

Draft
cleissonom wants to merge 1 commit into
nodejs:mainfrom
cleissonom:fix/styletext-nested-array
Draft

cleissonom wants to merge 1 commit into
nodejs:mainfrom
cleissonom:fix/styletext-nested-array

Conversation

@cleissonom

@cleissonom cleissonom commented Nov 24, 2026 •

Copy link
Copy Markdown

When util.styleText() receives an array of formats, closing a nested style can restore an overridden color instead of the active outer color. For example, with ['red', 'green'], the text after a nested blue span turns red even though green was applied last. Documented format order

Red and green share the same reset code. This PR fixes the restoration order by processing nested resets from the innermost format outward. The regression test covers named colors, hex colors, background colors, and the reset shared by bold and dim.

On a local macOS arm64 build, the regression test reproduced the bug before the fix. All five cases passed with the fix, and all 37 util test files passed. make lint passed. The full make test suite also passed with NO_COLOR unset.

I used Codex to help investigate the bug and prepare the fix and regression test. I reviewed the patch and ran local checks.

Fixes: #67746

Signed-off-by: Cleisson Moura <cleissonconstc@gmail.com>
Assisted-by: Codex
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

Caution

AgentScan found account activity patterns that may be consistent with automation. This is a heuristic, not proof that this pull request was opened by an agent or violates policy. AI-assisted contributions are permitted, but automated tooling must not open pull requests without advance approval, and contributors must personally understand, test, verify, and take responsibility for every submitted change. See the AgentScan analysis, AI use policy, and automation policy for additional context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentscan:mixed-signals needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

util: styleText restores overridden color after nested style when format is an array

2 participants